<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>远程控制显示系统 - 演示页面</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: #f0f2f5;
            height: 100vh;
            overflow: hidden;
        }

        .container {
            display: flex;
            height: 100vh;
        }

        .left-panel {
            width: 400px;
            background: white;
            border-right: 2px solid #e0e0e0;
            box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        }

        .right-panel {
            flex: 1;
            background: #000;
        }

        .panel-header {
            background: #f8f9fa;
            padding: 10px 15px;
            border-bottom: 1px solid #e0e0e0;
            font-weight: bold;
            color: #333;
            font-size: 0.9rem;
        }

        .left-panel .panel-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .right-panel .panel-header {
            background: #000;
            color: #fff;
        }

        iframe {
            width: 100%;
            height: calc(100% - 40px);
            border: none;
            background: white;
        }

        .right-panel iframe {
            background: #000;
        }

        .resize-handle {
            width: 4px;
            background: #ddd;
            cursor: col-resize;
            transition: background 0.3s;
        }

        .resize-handle:hover {
            background: #667eea;
        }

        .resize-handle:active {
            background: #764ba2;
        }

        .instructions {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background: rgba(0,0,0,0.8);
            color: white;
            padding: 15px;
            border-radius: 10px;
            font-size: 0.8rem;
            max-width: 300px;
            z-index: 1000;
        }

        .instructions h4 {
            margin-bottom: 10px;
            color: #667eea;
        }

        .instructions ul {
            list-style: none;
            padding-left: 0;
        }

        .instructions li {
            margin-bottom: 5px;
            padding-left: 15px;
            position: relative;
        }

        .instructions li:before {
            content: "•";
            color: #667eea;
            position: absolute;
            left: 0;
        }

        @media (max-width: 1200px) {
            .left-panel {
                width: 350px;
            }
        }

        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }
            
            .left-panel {
                width: 100%;
                height: 50%;
            }
            
            .right-panel {
                height: 50%;
            }
            
            .resize-handle {
                width: 100%;
                height: 4px;
                cursor: row-resize;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="left-panel">
            <div class="panel-header">
                📱 移动端控制客户端
            </div>
            <iframe src="mobile-test-client.html" title="移动端控制客户端"></iframe>
        </div>
        
        <div class="resize-handle" id="resizeHandle"></div>
        
        <div class="right-panel">
            <div class="panel-header">
                🖥️ 显示端
            </div>
            <iframe src="index.html" title="显示端"></iframe>
        </div>
    </div>

    <div class="instructions">
        <h4>使用说明</h4>
        <ul>
            <li>在左侧连接MQTT服务器</li>
            <li>设置目标主题和设备ID</li>
            <li>发送消息到右侧显示端</li>
            <li>可拖拽分隔线调整面板大小</li>
        </ul>
    </div>

    <script>
        // 拖拽调整面板大小功能
        const resizeHandle = document.getElementById('resizeHandle');
        const leftPanel = document.querySelector('.left-panel');
        const container = document.querySelector('.container');
        let isResizing = false;
        let startX, startWidth;

        resizeHandle.addEventListener('mousedown', (e) => {
            isResizing = true;
            startX = e.clientX;
            startWidth = leftPanel.offsetWidth;
            document.body.style.cursor = 'col-resize';
            e.preventDefault();
        });

        document.addEventListener('mousemove', (e) => {
            if (!isResizing) return;
            
            const deltaX = e.clientX - startX;
            const newWidth = Math.max(300, Math.min(600, startWidth + deltaX));
            leftPanel.style.width = newWidth + 'px';
        });

        document.addEventListener('mouseup', () => {
            isResizing = false;
            document.body.style.cursor = '';
        });

        // 响应式处理
        function handleResize() {
            if (window.innerWidth <= 768) {
                // 移动端布局
                container.style.flexDirection = 'column';
                leftPanel.style.width = '100%';
                leftPanel.style.height = '50%';
                resizeHandle.style.width = '100%';
                resizeHandle.style.height = '4px';
                resizeHandle.style.cursor = 'row-resize';
            } else {
                // 桌面端布局
                container.style.flexDirection = 'row';
                leftPanel.style.width = '400px';
                leftPanel.style.height = '100%';
                resizeHandle.style.width = '4px';
                resizeHandle.style.height = '100%';
                resizeHandle.style.cursor = 'col-resize';
            }
        }

        window.addEventListener('resize', handleResize);
        handleResize(); // 初始化

        // 添加键盘快捷键
        document.addEventListener('keydown', (e) => {
            if (e.ctrlKey || e.metaKey) {
                switch(e.key) {
                    case '1':
                        e.preventDefault();
                        document.querySelector('.left-panel iframe').focus();
                        break;
                    case '2':
                        e.preventDefault();
                        document.querySelector('.right-panel iframe').focus();
                        break;
                }
            }
        });

        // 页面加载完成后的提示
        window.addEventListener('load', () => {
            console.log('演示页面已加载完成');
            console.log('快捷键：Ctrl+1 聚焦左侧控制端，Ctrl+2 聚焦右侧显示端');
        });
    </script>
</body>
</html> 